package com.esfak47.mediafetcher.core.service;

import com.esfak47.common.extension.Adaptive;
import com.esfak47.common.extension.SPI;
import com.esfak47.mediafetcher.core.domain.FetchAble;
import com.esfak47.mediafetcher.core.domain.Media;

import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.function.Supplier;

/**
 * @author tony
 */
@SPI
public interface CrawlerService {
    @Adaptive
    default CompletableFuture<Optional<Media>> getVideoExtInfoAsync(FetchAble fetchAble) {
        return CompletableFuture.supplyAsync(this.getExtraInfo(fetchAble));
    }

    @Adaptive
    default Supplier<Optional<Media>> getExtraInfo(FetchAble fetchAble) {
        return () -> this.getVideoExtInfo(fetchAble);
    }

    @Adaptive
    Optional<Media> getVideoExtInfo(FetchAble fetchAble);
}
